﻿using System;
using System.Diagnostics;

namespace sinetd.Utilities
{
    public class Statistic
    {
        private Stopwatch sw;
        private Int64 flowIn;
        private Int64 flowOut;

        public Statistic()
        {
            sw = new Stopwatch();
        }

        public void Begin()
        {
            sw.Start();
        }

        public void FlowIn(int count)
        {
            flowIn += count;
        }

        public void FlowOut(int count)
        {
            flowOut += count;
        }

        public void Flow(int countIn, int countOut)
        {
            flowIn += countIn;
            flowOut += countOut;
        }

        public void End()
        {
            sw.Stop();
        }

        public string ToReport()
        {
            return "DataIn: " + flowIn + ", DataOut: " + flowOut + ", Time: " + sw.ElapsedMilliseconds + " ms";
        }
    }
}
